#include <bits/stdc++.h>
using namespace std;
int n, ans = -99999, k = 0, j = 0, ch = 0; string a;
int main(){
	cin >> n;
	cin >> a;
	char same = a[0]; 
	for(int i = 0; i < 2 * n; i++, j++){
		if(i == n) 
			j = 0;
		if(same == a[j]) 
			k++;
		else{
			if(ch == 1){
				ans = max(ans, k);
				k = 0;
				ch = 0;
			}
			else{
				k++;
				ch = 1;
				same = a[j];
			}
		}
	}
	cout << ans << endl;
	return 0;
}
/*
29
brbrrrbbbrrrrrbrrbbrbbbbrrrrb
*/